<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Title</title>
    <style>
        #app{
            width: 600px;
            height: 300px;
            background-color: aquamarine;
        }
        .son{
            width: 200px;
            height: 200px;
            background-color: yellow;
        }
    </style>

    <script src="./js/vue.min.js"></script>
</head>
<body>
    <div id="app">
        <h1>最大父组件,{{company}}</h1>
        <son @gifts="show($event)"></son>
    </div>
    <hr>
    <template id="son">
        <div class="son">
            <p>子组件,{{company}}</p>
            <button @click="sendGift">给父组件送礼物</button>
        </div>
    </template>

</body>
</html>
<script>
    var vm=new Vue(
        {
            el: "#app",
            data:{
                company:""
            },
            methods: {
                show(gift){
                  this.company=gift;
                }
            },
            components:{
                son:{
                    template: "#son",
                    data(){
                        return {
                            company:"熊猫TV"
                        }
                    },
                    methods:{
                        sendGift(){
                            this.$emit("gifts",this.company)
                        }
                    }
                }
            }
        }
    );

</script>